<%@page import="cn.edu.nju.ws.sview.wyge.relations.adataset.DocumentDataset"%>
<%@page import="java.util.HashSet"%>
<%@page import="cn.edu.nju.ws.sview.views.Group"%>
<%@page import="cn.edu.nju.ws.sview.wyge.relations.adataset.CustomDataset"%>
<%@page import="cn.edu.nju.ws.sview.wyge.relations.datasets.DatasetItem"%>
<%@page import="cn.edu.nju.ws.sview.wyge.relations.datasets.DatasetBrowsing"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="cn.edu.nju.ws.sview.util.URIUtil,java.net.URLEncoder,java.util.Enumeration,java.util.ArrayList,cn.edu.nju.ws.sview.util.URIUtil,cn.edu.nju.ws.sview.views.Entity,cn.edu.nju.ws.sview.views.data.EntityManagement,cn.edu.nju.ws.sview.views.data.EntityManagement.URIMember,cn.edu.nju.ws.sview.cache.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>数据集编辑</title>
<link rel="icon" href="/sview/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/sview/css/relations/dataset_create.css" />
<link rel="stylesheet" type="text/css" href="/sview/css/layout.css" />
<link rel="stylesheet" type="text/css" href="/sview/css/easyui.css" />
<script type="text/javascript" src="/sview/script/jquery.js"></script>
<script type="text/javascript" src="/sview/script/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/sview/script/global.js"></script>
<script type="text/javascript" src="/sview/script/relations/dataset_create.js"></script>
</head>
<body>
	<%
		String lang = request.getParameter("lang");
		if (lang != null && lang.equals("en")) {
			request.getRequestDispatcher("dataset_create.jsp").forward(
					request, response);
		} else if (lang == null) {
			lang = "zh";
		}
		
		String genre = request.getParameter("genre");
		String datasetIdStr =  request.getParameter("datasetId");
		int datasetId =0;
		String ds_type=null;
		if(genre==null){
			String location = "../relations/index.jsp";
			if(lang.equals("zh"))
				location = location+"?lang="+lang;
			response.sendRedirect(location);
			return;
		}else{
			datasetId = Integer.parseInt(datasetIdStr);
			ds_type = genre.equals("c")?"custom":"uri";
		}
		
		int gid = -1;
		if(request.getParameter("gid")!=null){
			gid = Integer.parseInt(request.getParameter("gid"));
		}else{
		System.out.println("going...no gid!");
			String location = "../relations/index.jsp";
			if(lang.equals("zh"))
				location = location+"?lang="+lang;
			response.sendRedirect(location);
			return;
		}
		String gname = null;
		try{
			gname = GroupNameIDCache.getInstance().getName(gid);
		}catch(Throwable e){
			e.printStackTrace();
		}
	%>
<jsp:include page="/vheader_zh.jsp" flush="true">
   <jsp:param name="f" value="d"/>
</jsp:include>
	<div class="container">
		<div class="top">
			<div class="mspacing"></div>
      		 <%
      			String name = DatasetItem.getShowNameByDatasetID(datasetId, ds_type, lang);
				if (genre.equals("c")){
//							name = CustomDataset.getNameByCustomDatasetID(datasetId);
							gname = (String)CustomDataset.getGroupByCustomDatasetId(datasetId);
							gid = Group.getGroupIdByName(gname);
//						} else if (genre.equals("u")) {
//							try {
//								name = URIIDCache.getInstance().getURI(datasetId);
//							} catch (Throwable e) {
//								e.printStackTrace();
//							}		
				}
      			String nameHref = "/sview/dataset/"+genre+datasetId;
      		%>			
			<div class="op"><a href=<%= nameHref%>><%=name %></a></div>
			<%
				//ArrayList<URIMember> array =EntityManagement.getInstance().getEntityMembers(etype,eid,lang) ;
				ArrayList<URIMember> array = DatasetBrowsing.getDatasetMembers(ds_type, datasetId, lang);
			%>
			<div class="omem">
			   <label>原始 URI</label>
			   	<ul>
			   	  <% for(URIMember member:array){
			   	       int memID = member.getURIID();
			   	       String uri = member.getURI();
			   	       String label = member.getLabel();
			   	       String href = "/sview/dataset/"+genre+memID;
			   	  %>
			   	  <li><a target="_blank" href="<%=href%>" title="<%=uri%>"><%=label %></a></li>
			   	  <%} %>
			   	</ul>
			</div>
			<div class="mspacing"></div>
		</div>
		<div class="mspacingLittle"></div>
		<div class="main">
		    <div class="create-box">
		         <a class="easyui-linkbutton create_button" iconCls='icon-create'
										href='javascript:void(0)'>新建数据集</a>
		    </div>
			<div class="mpanel">
				<div class="myentity">
					<div class="blue-header">
						<span class="title">当前组内数据集</span>
					</div>
					<ol class="leftnav"></ol>
					<div class="navfoot"></div>
				</div>
				<div class="leftPanel">
					<div class="entity-list"></div>
				</div>
				<div class='rightPanel'>
					<div class='recommendSection'>
						<div class="header">
							<span>相关数据集</span>
						</div>
						<div class="content">
							<ul class="entityList">
							</ul>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<input type="hidden" id="display-lang" value="zh" />
	<input type="hidden" id="genre" value="<%=genre %>" />
	<input type="hidden" id="etype" value="<%=ds_type %>" />
	<input type="hidden" id="eid" value="<%=datasetId %>" />
	<input type="hidden" id="gid" value="<%=gid %>" />
	<input type="hidden" id="gname" value="<%=gname %>" />
	<!-- <div class="warning">
	   <div class="warnBox">
	    <p>The uri has been member of entity <span class="ename">test</span>.</p> 
	    <p>Do you want to move members of <span class="ename">test</span> into this entity, 
	         <div>and delete <span class="ename">test</span> (Caution: deletion is unrecoverable)?</div>
	    </p>
	   </div>
	</div> -->
	<jsp:include page="/vfooter_zh.jsp"></jsp:include>
</body>
</html>